package com.wo.cloud.admin.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wo.cloud.admin.entity.SysMenu;
import com.wo.cloud.admin.mapper.SysMenuMapper;
import com.wo.cloud.admin.service.IMenuService;
import com.wo.cloud.admin.vo.SysMenuVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author liry
 * @version 1.0
 * @date Created on 2021/5/15 22:45
 * Description:
 */

@Service
public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> implements IMenuService {


    @Autowired
    private SysMenuMapper sysMenuMapper;


    @Override
    public IPage<SysMenu> selectPage(Page page, String name) {
        LambdaQueryWrapper<SysMenu> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        return sysMenuMapper.selectPage(page, lambdaQueryWrapper.like(StrUtil.isNotBlank(name), SysMenu::getName, name));
    }

    @Override
    public List<SysMenuVo> getTreeMenu(String roleId) {
        return sysMenuMapper.getTreeMenu(roleId);
    }

    @Override
    public List<String> getPermissions() {
        // 获取 role
        String roleId = "3";
        return sysMenuMapper.getPermissions(roleId);
    }
}
